Computer graphics refers to any processing device or program that makes a data processing system, such as a computer capable of displaying and manipulating (e.g., drawing, inputting, and outputting) graphics objects. Accordingly, processes of rendering information to be displayed may require a computer system have considerable memory and processing speed. Typically, a graphics processing unit (“GPU”) is used to process graphics objects, which lifts the burden off the central processing unit (“CPU”) which can then be used to perform other tasks.
In order to exploit multiple CPU threads, software can be written to use a producer consumer queue where one thread issues commands to a queue which are read by another thread for processing. This reduces the amount of time spent by a producer thread by dispatching the work to another thread. As commands are processed by a consumer thread, information is accumulated in data structures that are coherent with the consumer thread, but not with the producer thread. The producer thread often needs to retrieve information from the consumer thread or the GPU. However, since the queue may contain commands pending to be executed, the only way to ensure that the producer and consumer threads are synchronized is to ensure that the queue is empty and the GPU has completed all commands therein.
A conventional multithreaded graphics engine, such as Open Graphics Language or OpenGL™, forms a command queue between two threads. A producer thread can reside on the application main thread or in a drawing thread created by the application. A consumer thread is created along with the command queue (e.g., a first-in-first-out or FIFO queue). The command queue can contain many commands from the producer and is kept in synchronized using common mechanisms used in software FIFO's and queues. State queries in this architecture require the command queue to be emptied and the GPU to complete any commands dependent on this query. This can be a time consuming issue, as all the commands need to be processed by the consumer thread and finished by the GPU.